package com.zelin.search.web.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zelin.entity.vo.ItemVo;
import com.zelin.search.service.ItemSearchService;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * ------------------------------
 * 功能：
 * 作者：WF
 * 微信：hbxfwf13590332912
 * 创建时间：2021/8/2-12:36
 * ------------------------------
 */
@Controller
@RequestMapping
public class SearchController {

    @Reference(timeout = 5000)
    private ItemSearchService itemSearchService;
    /**
     * 功能: 根据条件进行查询
     * 参数:
     * params: 代表查询参数
     * model: 代表存放查询到的结果
     * 返回值: java.lang.String
     * 时间: 2021/8/2 16:00
     */
    @RequestMapping({"/","/search.html"})
    public String start(ItemVo vo, Model model){
        //1. 开始进行查询
        Map<String,Object> resultMap = itemSearchService.search(vo);
        model.addAttribute("resultMap",resultMap);
        model.addAttribute("vo",vo);
        return "search";
    }


}
